I have successfully used the syntax below to return an array of strings (for example) from a function:
string functionThatReturnsStringArray(int i)[] {
string str[];
int temp = (int get(arrayWithSimpleStringsArrayAsElements, i, 0));
str = (addr_ temp);
return (str);
}
// Usage:
string myStr[];
myStr = functionThatReturnsStringArray(20);
string functionThatReturnsStringArray(int i)[] {
string str[];
str = (string[] get(arrayWithSimpleStringsArrayAsElements, i, 0));
return (str);
}
SystemAdmin - Fri May 14 14:07:40 EDT 2010 |
Re: DXL Syntax for typecasting an array
It is actually very simple:
Array arrayWithSimpleStringsArrayAsElements = create(3,3)
string s[] = {"Hello","DXL"}
put (arrayWithSimpleStringsArrayAsElements ,s,0,0 )
string functionThatReturnsStringArray(int i)[] {
string str[];
str = get(arrayWithSimpleStringsArrayAsElements, i, 0) ;
return (str);
}
string myStr[];
myStr = functionThatReturnsStringArray(0);
print myStr[0] " " myStr[1] "\n"
string function(parameters)[] { ... }
syntax. I had a bad error once using this syntax which was very hard to track down ... It seems to work very nice, but somehow it messes up the stack once in a while - unfortunately I cannot give an example. Just an advice - If you ever run into weird problems in any program part that make no sense, and you are using a function with that syntax change it back to void func(string &par[]) which does the trick but seems to be more stable. Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS |
Re: DXL Syntax for typecasting an array Mathias Mamsch - Fri May 14 15:03:38 EDT 2010
It is actually very simple:
Array arrayWithSimpleStringsArrayAsElements = create(3,3)
string s[] = {"Hello","DXL"}
put (arrayWithSimpleStringsArrayAsElements ,s,0,0 )
string functionThatReturnsStringArray(int i)[] {
string str[];
str = get(arrayWithSimpleStringsArrayAsElements, i, 0) ;
return (str);
}
string myStr[];
myStr = functionThatReturnsStringArray(0);
print myStr[0] " " myStr[1] "\n"
string function(parameters)[] { ... }
syntax. I had a bad error once using this syntax which was very hard to track down ... It seems to work very nice, but somehow it messes up the stack once in a while - unfortunately I cannot give an example. Just an advice - If you ever run into weird problems in any program part that make no sense, and you are using a function with that syntax change it back to void func(string &par[]) which does the trick but seems to be more stable. Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS If you ever find that example where
string PtrOps_castAsStringArray(int address)[] {
string temp[];
temp = (addr_ address);
return (temp);
}
string functionThatReturnsStringArray()[] {
// ...
int address = someValidAddress();
return( PtrOps_castAsStringArray(address) );
}
|